import Vue from 'vue'
import Router from 'vue-router'

const ua = window.navigator.userAgent;
let path
if (ua.indexOf('iPad') >= 0) {
  path = '/iPad'
} else if (ua.indexOf('iPhone') >= 0) {
  path = '/mobile'
} else if (ua.indexOf('Android') >= 0) {
  path = '/mobile'
} else {
  path = ''
}

Vue.use(Router)

const router = new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '/login',
      meta: {
        title: '登陆'
      },
      name: "login",
      component: () => import('./views' + path + '/login/Login.vue')
    },
    {
      path: '/register',
      meta: {
        title: '注册'
      },
      name: "register",
      component: () => import('./views' + path + '/login/Register.vue')
    },
    {
      path: '/forget',
      meta: {
        title: '忘记密码'
      },
      name: "forget",
      component: () => import('./views' + path + '/login/Forget.vue')
    },
    {
      path: '/index',
      name: 'index',
      component: () => import('./views' + path + '/Index.vue')
    },
    {
      path: '/enter',
      name: 'enter',
      component: () => import('./views' + path + '/Enter.vue')
    },
    {
      path: '/dynamic',
      name: 'dynamic',
      redirect: '/dynamic/companyNews',
      component: () => import('./views' + path + '/Dynamic.vue'),
      children: [
        {
          path: 'companyNews', name: 'companyNews', meta: {
            title: '公司新闻'
          }, component: () => import('./views' + path + '/dynamic/companyNews.vue')
        },
        {
          path: 'companyAnnouncements', name: 'companyAnnouncements', meta: {
            title: '公司公告'
          }, component: () => import('./views' + path + '/dynamic/companyAnnouncements.vue')
        },
        {
          path: 'activityForecast', name: 'activityForecast', meta: {
            title: '活动预告'
          }, component: () => import('./views' + path + '/dynamic/activityForecast.vue')
        },
        {
          path: 'companyNews_details', name: 'companyNews_details', meta: {
            title: '公司新闻详情'
          }, component: () => import('./views' + path + '/dynamic/companyNews_details.vue')
        },
        {
          path: 'companyAnnouncements_details', name: 'companyAnnouncements_details', meta: {
            title: '公司公告详情'
          }, component: () => import('./views' + path + '/dynamic/companyAnnouncements_details.vue')
        },
        {
          path: 'activityForecast_details', name: 'activityForecast_details', meta: {
            title: '活动预告详情'
          }, component: () => import('./views' + path + '/dynamic/activityForecast_details.vue')
        },
      ]
    },
    {
      path: '/service',
      name: 'service',
      component: () => import('./views' + path + '/Service.vue'),
      redirect: "/service/culture",
      children: [
        {
          path: 'culture',
          meta: {
            title: '文化娱乐'
          },
          name: "culture",
          component: () => import('./views' + path + '/service/culture.vue')
        },
        {
          path: 'culture_details',
          meta: {
            title: '娱乐详情'
          },
          name: "culture_details",
          component: () => import('./views' + path + '/service/culture_details.vue')
        },
        {
          path: 'serve',
          meta: {
            title: '服务中心'
          },
          name: "serve",
          component: () => import('./views' + path + '/service/serve.vue')
        },
        {
          path: 'serve_details',
          meta: {
            title: '服务中心'
          },
          name: "serve_details",
          component: () => import('./views' + path + '/service/serve_details.vue')
        },
        {
          path: 'member',
          meta: {
            title: '会员中心'
          },
          name: "member",
          component: () => import('./views' + path + '/service/member.vue')
        },
        {
          path: 'consult',
          meta: {
            title: '咨询中心'
          },
          name: "consult",
          component: () => import('./views' + path + '/service/consult.vue')
        },
        {
          path: 'consult_details',
          meta: {
            title: '咨询中心详情'
          },
          name: "consult_details",
          component: () => import('./views' + path + '/service/consult_details.vue')
        },
      ]
    },
    {
      path: '/invest',
      name: 'invest',
      component: () => import('./views' + path + '/Invest.vue'),
      redirect: "/invest/investment",
      children: [
        {
          path: 'investment',
          name: 'investment',
          meta: {
            title: '投资新闻'
          },
          component: () => import('./views' + path + '/invest/investment.vue')
        },
        {
          path: 'investment_details',
          name: 'investment_details',
          meta: {
            title: '投资新闻详情'
          },
          component: () => import('./views' + path + '/invest/investment_details.vue')
        },
        {
          path: 'policy',
          meta: {
            title: '投资政策'
          },
          component: () => import('./views' + path + '/invest/policy.vue')
        },
        {
          path: 'environment',
          meta: {
            title: '投资环境'
          },
          component: () => import('./views' + path + '/invest/environment.vue')
        },
        {
          path: 'feature',
          meta: {
            title: '运营特色'
          },
          component: () => import('./views' + path + '/invest/feature.vue')
        },
        {
          path: 'hire',
          meta: {
            title: '商铺租赁'
          },
          component: () => import('./views' + path + '/invest/hire.vue')
        },
        {
          path: 'traffic',
          meta: {
            title: '区位交通'
          },
          component: () => import('./views' + path + '/invest/traffic.vue')
        },
      ]
    },
    {
      path: '/aboutus',
      name: 'aboutus',
      component: () => import('./views' + path + '/Aboutus.vue'),
      redirect: '/aboutus/synopsis',
      children: [
        {
          path: 'synopsis',
          name: 'synopsis',
          meta: {
            title: '集团简介'
          },
          component: () => import('./views' + path + '/aboutus/synopsis.vue')
        },
        {
          path: 'relation',
          name: 'relation',
          meta: {
            title: '联系我们'
          },
          component: () => import('./views' + path + '/aboutus/relation.vue')
        },
        {
          path: 'suggest',
          name: 'suggest',
          meta: {
            title: '意见建议'
          },
          component: () => import('./views' + path + '/aboutus/suggest.vue')
        },
        {
          path: 'recruit',
          name: 'aboutRecruit',
          meta: {
            title: '招纳贤士'
          },
          component: () => import('./views' + path + '/aboutus/recruit.vue')
        },

      ]
    },
  ]
})

export default router
